package yawning.mew.equipment;

import java.util.HashMap;
import java.util.Map;

import yawning.mew.equipment.RawItem.Property;

public class EquipSet {
	public enum Slot {
		HEAD,
		NECK,
		SHOULDER,
		BACK,
		CHEST,
		WRIST,
		HANDS,
		WAIST,
		LEGS,
		FEET,
		FINGER_1,
		FINGER_2,
		TRINKET_1,
		TRINKET_2,
		MAIN_HAND,
		OFF_HAND,
		RANGED
	}
	
	public Map<Slot,Item> equipmentMap = new HashMap<Slot,Item>();
	
	public void addItem(Item item) {
		int slotbak = item.mItem.properties.get(Property.SLOT);
		switch (slotbak) {
			case 1: equipmentMap.put(Slot.HEAD, item); break;
			case 2: equipmentMap.put(Slot.NECK, item); break;
			case 3: equipmentMap.put(Slot.SHOULDER, item); break;
			case 5: equipmentMap.put(Slot.CHEST, item); break;
			case 20: equipmentMap.put(Slot.CHEST, item); break;
			case 6: equipmentMap.put(Slot.WAIST, item); break;
			case 7: equipmentMap.put(Slot.LEGS, item); break;
			case 8: equipmentMap.put(Slot.FEET, item); break;
			case 9: equipmentMap.put(Slot.WRIST, item); break;
			case 10: equipmentMap.put(Slot.HANDS, item); break;
			case 11: 
				if (!equipmentMap.containsKey(Slot.FINGER_1)) equipmentMap.put(Slot.FINGER_1, item); 
				else equipmentMap.put(Slot.FINGER_2, item);
				break;
			case 12: 
				if (!equipmentMap.containsKey(Slot.TRINKET_1)) equipmentMap.put(Slot.TRINKET_1, item); 
				else equipmentMap.put(Slot.TRINKET_2, item);
				break;
			case 16: equipmentMap.put(Slot.BACK, item); break;
			case 17: equipmentMap.put(Slot.MAIN_HAND, item); break;
			case 28: equipmentMap.put(Slot.RANGED, item); break;
			case 19: equipmentMap.put(Slot.BACK, item); break;
			case 4: break; // Shirt
			default:
				System.out.println("** EquipSet: Unknown slot number " + slotbak + " for item: " + item.mItem);
				break;
		}
	}
	
	public int sumProperty(Property p) {
		int total = 0;
		for (Item i : equipmentMap.values()) total += i.sumProperty(p);
		return total;
	}
}

